<template>
    <div class="dialog">
        <el-dialog
            :title="dialog.title"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
            :modal-append-to-body="false"
            :visible.sync="dialog.show"
        >
            <el-form
                ref="StuForm"
                :model="StuForm"
                label-width="150px"
            >
                <el-form-item label="姓名:">
                    <el-input
                        v-model.number="StuForm.name"
                        placeholder="请输入姓名"
                    ></el-input>
                </el-form-item>

                <el-form-item label="年龄:">
                    <el-input
                        v-model="StuForm.age"
                        placeholder="请输入年龄"
                    ></el-input>
                </el-form-item>

                <el-form-item label="性别:">
                    <el-input
                        v-model.number="StuForm.sex"
                        placeholder="请输入性别"
                    ></el-input>
                </el-form-item>
                <el-form-item label="地址:">
                    <el-input
                        v-model="StuForm.address"
                        placeholder="请输入地址"
                    ></el-input>
                </el-form-item>
                <el-form-item label="电话:">
                    <el-input
                        v-model="StuForm.tel"
                        placeholder="请输入电话"
                    ></el-input>
                </el-form-item>
                <el-form-item label="身份证:">
                    <el-input
                        v-model="StuForm.identity"
                        placeholder="请输入身份证号"
                    ></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
        <el-button @click="handleclose()">取 消</el-button>
        <el-button type="primary" @click="handleAddEdit()"
        >确定</el-button>
      </span>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        name: "StuDialog",
        // 获取父亲传过来的值
        props:{
            dialog:{
                type:Object,
                default:()=>{}
            },
            StuForm:{
                type:Object,
                default:()=>{}
            },
        },
        data(){
            return{}
        },
        methods: {
            handleclose(){
                this.dialog.show = false;
            },
            handleAddEdit() {
              let obj={
                  id:this.StuForm._id,
                  name:this.StuForm.name,
                  age:this.StuForm.age,
                  address:this.StuForm.address,
                  tel:this.StuForm.tel,
                  sex:this.StuForm.sex,
                  identity:this.StuForm.identity
              };
              this.$emit("saveStu",obj);
              this.dialog.show=false;
            },
        }
    };
</script>
<style scoped>
</style>